<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件对象</title>

    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: antiquewhite;
        }
    </style>
</head>

<body>

    <div>

    </div>
</body>
<script>
    var div = document.querySelector('div');
    //默认写法
    //event可以用e来表示也没问题。
    div.onclick = function(event) {
        console.log(event);
    }


    div.addEventListener('click', function(e) {
        console.log(e);
    })


    //为了兼容性问题使用以下写法
    div.addEventListener('click', function(e) {
        e = e || Window.event;
        console.log(e);
    })
</script>


</html>